package com.ggh.handler;

import com.ggh.entity.RoomBeanP;
import com.ggh.entity.UserBean;
import com.ggh.websocket.PK_WebSocket_P;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Public_State_P {
	// 客户端线程池
	public static Map<String, PK_WebSocket_P> clients = new ConcurrentHashMap<String, PK_WebSocket_P>();
	// 客户端房间
	public static Map<String, RoomBeanP> roomMap = new LinkedHashMap<String, RoomBeanP>();
	// 窗口
	// public static CreaWindow win=new CreaWindow();
	// 开启记录
	public static boolean record = false;

	/**
	 * 检测用户是否在房间
	 */
	public static String isUser_room(int userid) {
		 // 遍历房间map集合
		for (String key : roomMap.keySet()) {
			 // 获取房间信息，循环用户
			RoomBeanP room = roomMap.get(key);
			for (UserBean user : room.getGame_userlist()) {
				if (user.getUserid() == userid) {
					// 返回房间号
					return room.getRoomno();

				}
			}
		}
		return "";
	}
}
